package com.sys.gradepaysys.controller.stuServlet;

import com.alibaba.fastjson.JSON;
import com.sys.gradepaysys.entity.Clazz;
import com.sys.gradepaysys.entity.ResultData;
import com.sys.gradepaysys.service.StudentService;
import com.sys.gradepaysys.service.StudentServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "getAllClazzServlet", value = "/getAllClazzServlet")
public class getAllClazzServlet extends HttpServlet {
    private StudentService studentService=new StudentServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Clazz> allClazz = studentService.getAllClazz();
        String s="";
        s = JSON.toJSONString(new ResultData<>(200,"登陆成功!",allClazz));
        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(s);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  doGet(request, response);
    }
}
